home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
MM3Tp.sea Folder
/
Made by Marksman
/
Sources
/
u
/
eventsMM_Demo.p
< prev
next >
Wrap
Text File
|
1994-01-16
|
6KB
|
256 lines
unit UeventsMM_Demo;
{ Copyright © 1994 George R. Cossey }
{ eventsMM_Demo Additional event handler routines
File name: eventsMM_Demo
Function: This module contains the extra event handler routines
These routines allow us to override events in the main loop,
and to handle unique events.
History: 1/16/94 Original by George Cossey
}
interface
uses
Printing, Folders, Sound,mmCommonMM_Demo,CommonMM_Demo;
{ ======================================================= }
{ ======================================================= }
{ Handle the OS event }
procedure DoOSEvent(var myEvent:EventRecord);
{ Handle special key combinations }
function HandleKey(var myEvent:EventRecord):Boolean;
{ Special disk inserted handling }
function HandleDisk(var myEvent:EventRecord):Boolean;
{ Handle our special Zooms }
procedure U_DoZoom(OldRect:Rect;whichWindow:WindowPtr);
{ Handle our special Moves }
procedure U_Moved(OldRect:Rect;whichWindow:WindowPtr);
{ Handle our special go aways }
procedure U_GoAway(whichWindow:WindowPtr);
{ Handle our special hits in our windows }
procedure U_InContent(var myEvent:EventRecord;whichWindow:WindowPtr);
{ Handle our special updates }
procedure U_Update(whichWindow:WindowPtr);
{ Handle our special activates }
procedure U_Activate(whichWindow:WindowPtr;Do_An_Activate:Boolean);
{ Handle our special activates }
procedure U_EnableMenus;
{ Let us into the main loop }
procedure ApplLoopMM_Demo;
{ Filter events from the main loop }
procedure ApplEventMM_Demo(var DoIt:Boolean;var myEvent:EventRecord);
{ Handle our special user events }
procedure Handle_UserEvent(TheUserEvent:UserEventPRec);
{ ======================================================= }
{ ======================================================= }
implementation
{ ======================================================= }
{ ======================================================= }
{ Routine: DoOSEvent }
{ Purpose: Handle DoOSEvents }
procedure DoOSEvent(var myEvent:EventRecord);
begin
if (BSR(BAND(myEvent.message, osEvtMessageMask), 24) = suspendResumeMessage) then
begin
if (BAND(myEvent.message,resumeFlag) = 0) then { Suspend }
InTheForeground := FALSE
else
InTheForeground := TRUE;
end;
end;
{ ======================================================= }
{ Routine: HandleKey }
{ Purpose: Allow us to filter key strokes and special key combinations }
{ Return TRUE if we let the main loop handle the key stroke }
function HandleKey(var myEvent:EventRecord):Boolean;
var
charCode:integer; { Key code }
ch:char; { Key pressed in Ascii }
CmdKeyPressed:Boolean; { Command key pressed }
OptionKeyPressed:Boolean; { Option key pressed }
ShiftKeyPressed:Boolean; { Shift key pressed }
theHandleKey:Boolean; { value to return }
begin
theHandleKey := TRUE; { Let the main loop handle it }
charCode := BAND(myEvent.message,charCodeMask); { Get the character }
ch := char(charCode); { Change it to ASCII }
CmdKeyPressed := (BAND(myEvent.modifiers,cmdKey) <> 0); { See if Command key is down }
OptionKeyPressed := (BAND(myEvent.modifiers,optionKey) <> 0); { See if Option key is down }
ShiftKeyPressed := (BAND(myEvent.modifiers,shiftKey) <> 0); { See if Shift key is down }
{ Add your code here }
HandleKey := theHandleKey; { Return if we let main routine handle it }
end;
{ ======================================================= }
{ Routine: HandleDisk }
{ Purpose: Allow us to handle disk inserted events specially }
{ Return TRUE if we let the main loop handle the key stroke }
function HandleDisk(var myEvent:EventRecord):Boolean;
var
theHandleDisk:Boolean; { value to return }
begin
theHandleDisk := TRUE; { Let the main loop handle it }
HandleDisk := theHandleDisk; { Return if we let main routine handle it }
end;
{ ======================================================= }
{ Routine: U_DoZoom }
{ Purpose: Allow us in to handle it }
procedure U_DoZoom(OldRect:Rect;whichWindow:WindowPtr);
begin
end;
{ ======================================================= }
{ Routine: U_Moved }
{ Purpose: Allow us in to handle it }
procedure U_Moved(OldRect:Rect;whichWindow:WindowPtr);
begin
end;
{ ======================================================= }
{ Routine: U_GoAway }
{ Purpose: Allow us in to handle it }
procedure U_GoAway(whichWindow:WindowPtr);
begin
end;
{ ======================================================= }
{ Routine: U_InContent }
{ Purpose: Allow us in to handle it }
procedure U_InContent(var myEvent:EventRecord;whichWindow:WindowPtr);
begin
end;
{ ======================================================= }
{ Routine: U_Update }
{ Purpose: Allow us in to handle it }
procedure U_Update(whichWindow:WindowPtr);
begin
end;
{ ======================================================= }
{ Routine: U_Activate }
{ Purpose: Allow us in to handle it }
procedure U_Activate(whichWindow:WindowPtr;Do_An_Activate:Boolean);
begin
end;
{ ======================================================= }
{ Routine: U_EnableMenus }
{ Purpose: Allow us in to handle it }
procedure U_EnableMenus;
begin
end;
{ ======================================================= }
{ Routine: ApplLoopMM_Demo }
{ Purpose: At the top of the main loop, called each time thru the main }
{ loop. This is very often if WNE was false. }
procedure ApplLoopMM_Demo;
begin
end;
{ ======================================================= }
{ Routine: ApplEventMM_Demo }
{ Purpose: Allow us to filter all events before the main loop handles them }
{ Set DoIt to TRUE to let the main loop handle the event. }
procedure ApplEventMM_Demo(var DoIt:Boolean;var myEvent:EventRecord);
begin
DoIt := TRUE; { Let the main loop handle it }
if (WNE) then { Check for mouse in cursor area available }
begin
{ Check cursor region for possible cursor shape change, cursorRgn }
end;
if (myEvent.what = 0) then { Handle a NULL event}
DoIt := FALSE; { Tell the main loop to skip it}
end;
{ ======================================================= }
{ Routine: Handle_UserEvent }
{ Purpose: Handle our special user events }
procedure Handle_UserEvent(TheUserEvent:UserEventPRec);
begin
end;
{ ======================================================= }
{ ======================================================= }
end.